﻿using Microsoft.VisualStudio.Text;
using System.Threading;
using VSAdditionalCommands.ToolWindows.DublicateFilesToolWindow;
using VSAdditionalCommands.ToolWindows.ReplaceKeepCaseToolWindow;

namespace VSAdditionalCommands
{
    [Command(PackageIds.DublicateFilesToolWindowCommand)]
    internal sealed class DublicateFilesToolWindowCommand : BaseCommand<DublicateFilesToolWindowCommand>
    {
        protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
        {
            await Package.JoinableTaskFactory.SwitchToMainThreadAsync();
            await Package.JoinableTaskFactory.RunAsync(async delegate
            {
                DublicateFilesToolWindow window = (await Package.ShowToolWindowAsync(typeof(DublicateFilesToolWindow), 0, true, Package.DisposalToken)) as DublicateFilesToolWindow;
                if ((null == window) || (null == window.Frame))
                {
                    throw new NotSupportedException("Cannot create tool window");
                }
            });
        }
    }
}
